package com.jf.core;

import com.jfinal.aop.Interceptor;
import com.jfinal.core.ActionInvocation;
import com.jfinal.core.Controller;
import com.shop.bean.UserBean;
import com.shop.utils.StringUtils;

/**
 * 权限拦截器  判断用户是否已经登录
 * @author Administrator
 *
 */
public class AuthInterceptor implements Interceptor {

	@Override
	public void intercept(ActionInvocation ai) {
		Controller contr = ai.getController();
		UserBean user = contr.getSessionAttr("user");
		
		if(user != null){
			ai.invoke();
		}else{
			contr.setSessionAttr("url", ai.getActionKey());
			contr.forwardAction("/urc/lgnpage");
			//contr.redirect(contr.getRequest().getContextPath()+"/urc/lgnpage?jessionid="+StringUtils.getTimeCode());
		}

	}

}
